<template>
<div>
  <div id="showfrom" style="height:500px;width:500px"></div>
</div>
</template>

<script>
import * as echarts from "echarts";
import axios from "axios";

export default {
  name: "showintegral",
  data(){
    return{
      formlist:[]
    }
  },
  methods:{
    //实例化图形
    init(){
      let showfrom = document.getElementById('showfrom')
      var myChart = echarts.init(showfrom);
      var option;

      option = {
        title: {
          text: '用户积分 ',
          subtext: 'Fake Data',
          left: 'center'
        },
        tooltip: {
          trigger: 'item'
        },
        legend: {
          orient: 'vertical',
          left: 'left'
        },
        series: [
          {
            name: 'Access From',
            type: 'pie',
            radius: '50%',
            data: this.fromlist,
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      };
      option && myChart.setOption(option);
    },
    get_list(){
      axios({url:'http://localhost:8000/showintegral',method:'get'}).then(res=>{
        if(res.data.code==200){
          this.fromlist=res.data.list
          this.init()
        }
      })
    }
  },
  mounted() {
    this.get_list()
  }
}
</script>

<style scoped>

</style>